package rpc.client;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import net.sf.cglib.proxy.Enhancer;
import rpc.pojo.User;

public class Controller {

    public static void main(String[] args) {
        ProxyInterceptor proxyInterceptor=new ProxyInterceptor();
        Enhancer enhancer=new Enhancer();
        enhancer.setSuperclass(IUserService.class);//被代理的类
        enhancer.setCallback(proxyInterceptor);//设置增强方法
        IUserService userService= (IUserService) enhancer.create();
        User user = userService.getUserById(6);
        System.out.println(JSON.toJSONString(user));
    }

}
